Ext.define("ECAT.view.ButtomBar", {
    extend: 'Ext.Container',
    requires: ['Ext.Button','ECAT.view.Itemize','ECAT.view.Favorite','ECAT.view.ContactDetailView'],
    xtype : 'buttombar',
    config : { 
    	cls : 'touming toolbar',
    	hidden : true,
    	width: "100%",
    	bottom :0
    },
    initialize: function() {
    	this.callParent(arguments);
    	this.setHeight(ECAT.lib.BUTTOM_BAR_HEIGHT);
    	this.btn_menu = Ext.create('Ext.Button',{
    		id : 'btn_menu_down',
    		width: ECAT.lib.MENU_HEIGHT_WIDTH,
	  		height: ECAT.lib.MENU_HEIGHT_WIDTH,
    	    left: '5%',
    	    top : ECAT.lib.MENU_BTN_TOP,
    	    ui : 'plain',
    	    icon : 'resources/images/icons/down.png',
    	    iconCls : 'icon-btn-menu'
    	});
    	this.btn_all = Ext.create('Ext.Button',{
    		id : 'btn_all',
    		width: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
	  		height: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
    	    left: '25%',
    	    top : ECAT.lib.MENU_BTN_TOP,
    	    ui : 'plain',
    	    icon : 'resources/images/icons/all_h.png',
    	    iconCls : 'icon-btn-bar'
    	});
    	this.btn_itemize = Ext.create('Ext.Button',{
    		id : 'btn_itemize',
    		width: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
	  		height: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
    	    left: '45%',
    	    top : ECAT.lib.MENU_BTN_TOP,
    	    ui : 'plain',
    	    icon : 'resources/images/icons/itemize.png',
    	    iconCls : 'icon-btn-bar'
    	});
    	this.btn_fav = Ext.create('Ext.Button',{
    		id : 'btn_fav',
    		width: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
	  		height: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
    	    left: '65%',
    	    top : ECAT.lib.MENU_BTN_TOP,
    	    ui : 'plain',
    	    icon : 'resources/images/icons/fav.png',
    	    iconCls : 'icon-btn-bar'
    	});
    	this.btn_link = Ext.create('Ext.Button',{
    		id : 'btn_link',
    		width: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
	  		height: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
    	    left: '85%',
    	    top : ECAT.lib.MENU_BTN_TOP,
    	    ui : 'plain',
    	    icon : 'resources/images/icons/link.png',
    	    iconCls : 'icon-btn-bar',
    	    handler : function(){
				var topbar = Ext.getCmp('topbar'),
					buttombar = Ext.getCmp('buttombar'),
					contactDetailView = Ext.getCmp('contactDetailView');
				if(!contactDetailView){
					contactDetailView = Ext.create("ECAT.view.ContactDetailView");
				}
				Ext.Viewport.setActiveItem(contactDetailView);
				buttombar.setBtn('btn_link');
				topbar.toContactDetailView();
				contactDetailView.element.dom.style.top = '90px';
    	    }
    	});
    	this.ct_jiantou = Ext.create('Ext.Container',{
    		id : 'jiantou',
    		cls : 'jiantou',
    		left : '25%',
    		bottom : 0,
	    	width: ECAT.lib.MENU_BTN_HEIGHT_WIDTH,
	  		height: ECAT.lib.BUTTOM_BAR_HEIGHT-ECAT.lib.MENU_BTN_TOP-ECAT.lib.MENU_BTN_HEIGHT_WIDTH
    	});
    	this.add([this.btn_menu,this.btn_all,this.btn_itemize,this.btn_fav,this.btn_link,this.ct_jiantou]);
    },
    setBtn : function(btnId){
    	this.setBtnIcon(btnId);
    	this.setJianTouPosition(btnId);
    	this.setMenuBtn(btnId);
    },
    setMenuBtn : function(btnId){
    	var btn = this.btn_menu;
    	switch(btnId){
	    	case 'btn_all' :
	    		btn.enable();
				break;
			case 'btn_itemize' : 
				btn.disable();
				break;
			case 'btn_fav' : 
				btn.enable();
				break;
			case 'btn_link' : 
				btn.disable();
				break;
    	};
    },
    setJianTouPosition : function(btnId){
    	var ct_jiantou = this.ct_jiantou;
    	switch(btnId){
	    	case 'btn_all' :
	    		ct_jiantou.setLeft('25%');
				break;
			case 'btn_itemize' : 
				ct_jiantou.setLeft('45%');
				break;
			case 'btn_fav' : 
				ct_jiantou.setLeft('65%');
				break;
			case 'btn_link' : 
				ct_jiantou.setLeft('85%');
				break;
    	};
    },
    setBtnIcon : function(btnId){
    	if(btnId === 'btn_all'){
    		this.btn_all.setIcon(ECAT.lib.getIconSrc('all_h'));
    	}else{
    		this.btn_all.setIcon(ECAT.lib.getIconSrc('all'));
    	}
    	if(btnId === 'btn_itemize'){
    		this.btn_itemize.setIcon(ECAT.lib.getIconSrc('itemize_h'));
    	}else{
    		this.btn_itemize.setIcon(ECAT.lib.getIconSrc('itemize'));
    	}
    	if(btnId === 'btn_fav'){
    		this.btn_fav.setIcon(ECAT.lib.getIconSrc('fav_h'));
    	}else{
    		this.btn_fav.setIcon(ECAT.lib.getIconSrc('fav'));
    	}
    	if(btnId === 'btn_link'){
    		this.btn_link.setIcon(ECAT.lib.getIconSrc('link_h'));
    	}else{
    		this.btn_link.setIcon(ECAT.lib.getIconSrc('link'));
    	}
    }
});